package com.blog.cloud.controller.rec.login;

import com.blog.cloud.comm.modal.dto.ResponeObj;
import com.blog.cloud.comm.modal.pojo.User;
import com.blog.cloud.controller.base.BaseController;
import com.blog.cloud.service.UserService;
import com.jfinal.core.ActionKey;

public class LoginController extends BaseController {
	
	public void index(){
		String responeJspPrefix = super.getResponeJspPrefix("rec_login.jsp");
		//responeJspPrefix = super.getResponeJspPrefix("_layout_login.jsp");
		render(responeJspPrefix);
	}
	
	
	@ActionKey("login")
	public void login(){
		
		String basePar = "log-";
		String email = getPara(basePar+"email");
		String pwd = getPara(basePar+"password");
		ResponeObj ro = new ResponeObj("100","登录失败!",null);
		User user = UserService.ser.selectUserByEmail(email, pwd);
		if(user!=null){
			if("0".equals(user.getIsDelete())){
				setSessionAttr("user", user);
				//ro.setCode("200");
				//ro.setMessage("登录成功！");
				redirect("/blog");
			}
		}
		//renderJson(ro);
	}

}
